package sk.xorty.si;

import org.apache.log4j.Logger;
import org.springframework.integration.Message;
import org.springframework.integration.splitter.AbstractMessageSplitter;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Payload (from JDBC) => array of messages
 */
@Component
public class MessageSplitter extends AbstractMessageSplitter {

    @Override
    protected Object splitMessage(Message<?> message) {
        List<?> messages = (List<?>) message.getPayload();

        System.out.println("======== SPLITTER invoked ========");
        for (Object msg : messages) {
            System.out.println("\tsplitting msg: " + msg);
        }

        return messages;
    }

}
